<template>
	<view>
		<textarea class="txtArea" v-model="txtContent" :placeholder="placeHolder" :maxlength="maxLength"></textarea>
		<button class="comBtn" :disabled="isDisabledFlag" @tap="save">提交评论</button>
	</view>
</template>

<script>
	/* 暂时给问答下添加问题回复使用，课程添加评论目前使用和咨询订单一样的页面addGroupOrderPj  另外再给短视频/文章评论*/
	import { addMindAck } from '@/api/ansQue/index'
	export default {
		data(){
			return{
				isDisabledFlag:false,
				txtContent:'',
				resId:'',
				fromPage:'',//queDetPage//问答详情回复时  dspPage wzPage(dspPage) courseVidePage 
				maxLength:200,
				placeHolder:'请输入您的评论(200字内)'
			}
		},
		onLoad(options){
			this.fromPage = options.fromPage;
			this.resId = options.resId;
			if(this.fromPage == 'queDetPage'){
				this.maxLength = 1000;
				this.placeHolder = '请输入您的评论(1000字内)'
			}
		},
		methods:{
			save(){
				if(this.txtContent == ''){
					this.util.showToast('请输入您的评论');
					return;
				}
				uni.showLoading({title:'提交中...', mask: true });
				this.isDisabledFlag = true;
				var field = { parentId:this.resId,askContent:this.util.replaceToBr(this.txtContent)};
				addMindAck(field).then(res=>{
					this.util.showToastSuc('添加成功');
					let pages = getCurrentPages();
					let prevPages = pages[pages.length-2];
					prevPages.$vm.isRefreshFlag = true;
					setTimeout(()=>{
						uni.navigateBack({
							delta:1
						})
					},1500);
				}).catch(err=>{
					this.isDisabledFlag = false;
				});
			}
		}
	}
</script>

<style lang='scss' scoped>
	.txtArea{
		width: 96%;
		height: 580rpx;
		background: $pss-bg-gray;
		color: $pss-text-color3;
		font-size: $font-size30;
		padding: 2%;
	}
	.comBtn{
		width: 690rpx;
		margin: 100rpx auto 0;
		border-radius: 50rpx;
	}
</style>